import {
  AsyncStorage,
  NativeModules,
} from 'react-native';

export function setItemSimple(key, value){
  NativeModules.H5Storage.setItem(key, value);
}

export function getItemSimple(key, onSuccess){
  NativeModules.H5Storage.getIten(key, onSuccess);
}

export function removeItemSimple(key){
  NativeModules.H5Storage.removeItem(key);
}

export function setItem(key, value) {
  value = value.toString();
  AsyncStorage.setItem(key, value);
}

export async function getItem(key) {
  if (key instanceof Array) {
    const value = await AsyncStorage.multiGet(key);
    return value;
  } else {
    const value = await AsyncStorage.getItem(key);
    return value;
  }
}

export function removeItem(key){
  if (key instanceof Array) {
    AsyncStorage.multiRemove(key);
  } else {
    AsyncStorage.removeItem(key);
  }
}